﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddCity.aspx.cs" Inherits="NJL.WebManage.Citys.AddCity" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#btnSubmit').submit(function () {
                var regInt = /^\d+$/;
                var txtSort = $('#<%=txtSort.ClientID %>').val();
                if (txtSort.match(regInt) == null) {
                    alert('排序只能输入数字哦');
                    return false;
                }
                //地区选择
                var selectArea = document.getElementById("<%=ddlProvince.ClientID %>");
                if (selectArea != null) {
                    if (selectArea.value == "000000") {
                        alert("请选择地区");
                        return false;
                    }
                }
                //地区名
                var txtAreaName = $('#txtAreaName').val();
                if ($.trim(txtAreaName).length == 0) {
                    alert('地区名不能为空哦');
                    return false;
                }

            });
        });
        function textboxSelect() {
            var checkbox = document.getElementsByName("cbxSingle");
            for (var i = 0; i < checkbox.length; i++) {
                checkbox[i].checked = !checkbox[i].checked;
            }
        }
        function checkCheckboxState() {
            var checkbox = document.getElementsByName("cbxSingle");
            var hiddenId = "";
            var count = 0;
            for (var i = 0; i < checkbox.length; i++) {
                if (checkbox[i].checked == true) {
                    hiddenId += checkbox[i].value + ",";
                    count++;
                }
            }
            if (count == 0) {
                alert('请选择您要删除的记录')
                return false;
            }
            else {
                if (window.confirm("您确定要删除该记录？")) {
                    hiddenId = hiddenId.substring(0, hiddenId.length - 1);
                    document.getElementById("<%=HSelectId.ClientID %>").value = hiddenId;
                }
                else {
                    return false;
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div class="gray_bd">
        <div class="table_title">
            地区管理-添加地区
        </div>
        <div class="pad5px">
            <table align="center" cellspacing="0" style="width: 100%">
                <tr>
                    <td style="width: 120px; text-align: right;">
                        排序：
                    </td>
                    <td>
                        <asp:TextBox ID="txtSort" runat="server" Width="50px">0</asp:TextBox>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td style="width: 120px; text-align: right;">
                        地区：
                    </td>
                    <td>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <asp:DropDownList ID="ddlProvince" runat="server" OnSelectedIndexChanged="ddlProvince_SelectedIndexChanged"
                                    AutoPostBack="True">
                                </asp:DropDownList>
                                &nbsp;<asp:DropDownList ID="ddlCity" runat="server">
                                </asp:DropDownList>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td style="width: 120px; text-align: right;">
                        地区名称：
                    </td>
                    <td>
                        <asp:TextBox ID="txtAreaName" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Style="height: 21px"
                            Text="提交" Width="40px" />
                        <input id="btnCel" type="button" value="取消" onclick="location.href=location.href"
                            runat="server" visible="false" />
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
            </table>
            <hr />
            <div>
                <asp:DropDownList ID="ddlSearchProvince" runat="server">
                </asp:DropDownList>
                &nbsp;&nbsp;地区名:
                <asp:TextBox ID="txtKeywords" runat="server"></asp:TextBox>
            &nbsp;
                <asp:Button ID="btnSearch" runat="server" onclick="btnSearch_Click" Text="搜索" />
            </div>
            <div class="border_b_dotted">
                <table class="tableliststyle" cellspacing="0" rules="all" border="1" id="demo">
                    <tr class="gridheader">
                        <th style="width: 40px;">
                            <input id="cbxAll" type="checkbox" onclick="textboxSelect()" />
                        </th>
                        <th>
                            序号
                        </th>
                        <th>
                            地区名称
                        </th>
                        <th>
                            所属地区
                        </th>
                        <th>
                            排序
                        </th>
                        <th>
                            创建时间
                        </th>
                        <th>
                            编辑
                        </th>
                        <th>
                            删除
                        </th>
                    </tr>
                    <asp:Repeater ID="rptUserList" runat="server">
                        <ItemTemplate>
                            <tr>
                                <td align="center">
                                    <input id="<%#Eval("ID") %>" type="checkbox" value="<%#Eval("ID") %>" name="cbxSingle" />
                                </td>
                                <td align="center">
                                    <%#Container.ItemIndex + 1%>
                                </td>
                                <td align="left">
                                    <%#Eval("CUSTOM_AREA_NAME").ToString()%>
                                </td>
                                <td align="left">
                                    <asp:Literal ID="litArea" runat="server"></asp:Literal>
                                </td>
                                <td align="right">
                                    <%#Eval("Sort")%>
                                </td>
                                <td align="center">
                                    <%#Eval("CREATE_DATE_TIME","{0:yyyy-MM-dd HH:mm:ss}")%>
                                </td>
                                <td align="center">
                                    <asp:LinkButton ID="lbntEdit" runat="server" CommandName="Edit" CommandArgument='<%#Eval("ID") %>'>编辑</asp:LinkButton>
                                </td>
                                <td align="center">
                                    <asp:LinkButton ID="lbtnDel" runat="server" CommandName="Del" CommandArgument='<%#Eval("ID") %>'
                                        OnClientClick="return confirm('您确定要删除该信息吗？')">删除</asp:LinkButton>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
                <div style="text-align: left; margin-top: 5px;">
                    <asp:Button ID="btnDel" runat="server" Text="删除" OnClientClick="return checkCheckboxState()"
                        OnClick="btnDel_Click1" />
                </div>
            </div>
        </div>
    </div>
    <asp:HiddenField ID="HSelectId" runat="server" />
    </form>
</body>
</html>
